#8个老师随机分配三个办公室
# import random
# office = [[], [], []]
# teacher = ['t1', 't2', 't3', 't4', 't5', 't6', 't7', 't8']
# for t in teacher:
#     of = random.randint(0, 2)
#     office[of].append(t)
# print(office)
# i = 0
# for x in office:
#     i += 1
#     print('第%d个办公室有%d个人,是:' % (i, len(x)), end='')
#     for n in x:
#         print(n, end='\t')
#     print('\n')

# import random
# room = [[],[],[]]
# sir = ['s1','s2','s3','s4','s5','s6','s7','s8']
# for s in sir:
#     ro = random.randint(0,2)
#     room[ro].append(s)
# print(room)

#求100以内能被3整除的数，并将作为列表输出
# list1 =[]
# for i in range(101):
#     if i%3==0:
#         list1.append(i)
# print(list1)

# list2=[]
# for i in range(101):
#     if i %3 ==0:
#         list2.append(i)
# print(list2)

#斐波那契数列
# lis1 = []
# n, a, b = 0, 0, 1
# while n < 10:
#     lis1.append(b)
#     a, b = b, a + b
#     n = n + 1
# print(lis1)

# list2=[]
# n=0
# a=0
# b=1
# while n < 10:
#     list2.append(b)
#     a,b=b,a+b
#     # a=b
#     # b=a+b
#     n=n+1
# print(list2)

# list1 = ['name','age','gender']
# list2 = ['Tom','Timi','tensent']
# dict1 ={}
# for n in range(len(list2)):
#     dict1[list1[n]] = list2[n]
# print(dict1)

#有一堆字符串，“welocme to super&Test”，打印出superTest，#不能查字符的索引
# str1 ="welocme to super&Test"
# str1_split=str1.split(" ")
# for i in str1_split:
#     if "&"in i:
#         str2 =i.replace("&"," ")
# print(str2)

#有一堆字符串，“welocme to super&Test”，打印出superTest，#不能查字符的索引
# str2="welocme to super&Test"
# str_qiepian=str2.split(' ')
# for i in str_qiepian:
#     if '&'in i :
#         str2 = i.replace('&',' ')
# print(str2)

#有一堆字符串“aabbbcddef”打印出不重复的字符串结果：cef #不允许用类型转化
# list1 = "aabbbcddef"
# list2=""
# for i in list1:
#     if list1.count(i)>1:
#         continue
#     else:
#         list2 =list2+i
# print(list2)

# liebiao1='aabbbcddef'
# liebiao2=''
# for i in liebiao1:
#     if liebiao1.count(i)>1:
#         continue
#     else:
#         liebiao2=liebiao2+i
# print(liebiao2)

#列表[1,2,3,4,3,4,2,5,5,8,9,7],将此列表去重，得到一个唯一元素的列表  #不允许用强制类型转化
# list2 = [1, 2, 3, 4, 3, 4, 2, 5, 5, 8, 9, 7]
# list3 = []
# for i in list2:
#     if i not in list3:
#         list3.append(i)
# print(list3)

# list1=[1, 2, 3, 4, 3, 4, 2, 5, 5, 8, 9, 7]
# list2=[]
# for i in list1:
#     if i not in list2:
#         list2.append(i)
# print(list2)

#求100以内的质数（只能被1和它本身整除）
# list1=[]
# for i in range(3,101):
#     for n in range(2,i):
#         if i%n==0:
#             break
#     else:
#         list1.append(i)
# print(list1)

# list2=[]
# for i in range(3,101):
#     for n in range(2,i):
#         if i%n==0:
#             break
#     else:
#         list2.append(i)
# print(list2)

#有一堆字符串，“welocme to super&Test”，打印出tseT&repus ot  #不允许用reverse,和reversed
# str1 ="welocme to super&Test"
# # print(str1[::-1])

# list1 =list(str1)
# for i in range(len(str1)//2):
#     list1[i],list1[-i-1]=list1[-i-1],list1[i]
# print(''.join(list1))

# str2='welocme to super&Test'
# # print(str2[::-1])
#
#
# list1=list(str2)
# for i in range(len(str2)//2):
#     list1[i],list1[-i-1]=list1[-i-1],list1[i]
# print(''.join(list1))

#有一堆字符串，“abcdef”，将首尾反转，结果：fedcba，不能使用现有的函数或方法，自己写算法实现,不允许用步长
# str1 = "abcdef"
# list1=[]
# for i in str1:
#     list1.append(i)
# for n in range(len(list1)//2):
#     list1[n],list1[-n -1]=list1[-n -1],list1[n]
# #print(list1)
# str2 = ''
# for a in list1:
#     str2+=a
# print(str2)

# str2='abcdef'
# list2=[]
# for i in str2:
#     list2.append(i)
# for n in range(len(list2)//2):
#     list2[n],list2[-n-1]=list2[-n -1],list2[n]
# print(list2)
# # # str3=''
# # # for a in list2:
# # #     str2+=a
# # # print(str3)

#有一堆字符串，“aabbbcddef”，输出abcdef # 不允许用set
# str1='aabbbcddef'
# str2=''
# for i in str1:
#     if i not in str2:
#         str2+=i
# print(str2)

# str2='aabbbcddef'
# str3=''
# for i in str2:
#     if i not in str3:
#         str3+=i
# print(str3)

